<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/9
 * Time: 14:54
 */

namespace App\Http\Model;


class CategoryModel extends CommonModel {

    protected $table      = 'category';
    protected $primaryKey = 'CateId';
    protected $fillable   = ['CateName','CatePreview','CateParentId'];


    public function __construct(array $attributes=[]) {
        parent::__construct($attributes);
    }

    public function getAllData(array $fiels=null) {
        return self::where('CateStatus',0)->get($fiels);
    }

    public function getParentCategories(array $fiels=null) {
        return self::where('CateStatus',0)->where('CateParentId',null)->get($fiels);
    }

    public function getChildCategories($parentId, array $fiels=null) {
        return self::where('CateStatus',0)->where('CateParentId',$parentId)->get($fiels);
    }


}